<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>SFML - Simple and Fast Multimedia Library</title>
        <meta http-equiv="Content-Type" content="text/html;"/>
        <meta charset="utf-8"/>
        <!--<link rel='stylesheet' type='text/css' href="https://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic"/>-->
        <link rel="stylesheet" type="text/css" href="doxygen.css" title="default" media="screen,print" />
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript" src="dynsections.js"></script>
        <link rel="stylesheet" type="text/css" href="search/search.css" />
        <link rel="stylesheet" type="text/css" href="searchOverrides.css" />
        <script type="text/javascript" src="search/searchdata.js"></script>
        <script type="text/javascript" src="search/search.js"></script>
        <script type="text/javascript">
        /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
          $(document).ready(function() { init_search(); });
        /* @license-end */
        </script>
    </head>
    <body>
        <div id="banner-container">
            <div id="banner">
                <span id="sfml">SFML 2.6.1</span>
            </div>
        </div>
        <div id="content">
<!-- Generated by Doxygen 1.9.7 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <span id="MSearchSelect"                onmouseover="return searchBox.OnSearchSelectShow()"                onmouseout="return searchBox.OnSearchSelectHide()">&#160;</span>
          <input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>sf</b></li><li class="navelem"><a class="el" href="classsf_1_1TcpListener.html">TcpListener</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-types">Protected Types</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="classsf_1_1TcpListener-members.html">List of all members</a>  </div>
  <div class="headertitle"><div class="title">sf::TcpListener Class Reference<div class="ingroups"><a class="el" href="group__network.html">Network module</a></div></div></div>
</div><!--header-->
<div class="contents">

<p><a class="el" href="classsf_1_1Socket.html" title="Base class for all the socket types.">Socket</a> that listens to new TCP connections.  
 <a href="classsf_1_1TcpListener.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="TcpListener_8hpp_source.html">SFML/Network/TcpListener.hpp</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for sf::TcpListener:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classsf_1_1TcpListener.png" usemap="#sf::TcpListener_map" alt=""/>
  <map id="sf::TcpListener_map" name="sf::TcpListener_map">
<area href="classsf_1_1Socket.html" title="Base class for all the socket types." alt="sf::Socket" shape="rect" coords="0,56,105,80"/>
<area href="classsf_1_1NonCopyable.html" title="Utility class that makes any derived class non-copyable." alt="sf::NonCopyable" shape="rect" coords="0,0,105,24"/>
  </map>
</div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-types" name="pub-types"></a>
Public Types</h2></td></tr>
<tr class="memitem:a51bf0fd51057b98a10fbb866246176dc"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1Socket.html#a51bf0fd51057b98a10fbb866246176dc">Status</a> { <br />
&#160;&#160;<a class="el" href="classsf_1_1Socket.html#a51bf0fd51057b98a10fbb866246176dca1de3a85bc56d3ae85b3d0f3cfd04ae90">Done</a>
, <a class="el" href="classsf_1_1Socket.html#a51bf0fd51057b98a10fbb866246176dca8554848daae98f996e131bdeed076c09">NotReady</a>
, <a class="el" href="classsf_1_1Socket.html#a51bf0fd51057b98a10fbb866246176dca181c163fad2eaea927185d127c392706">Partial</a>
, <a class="el" href="classsf_1_1Socket.html#a51bf0fd51057b98a10fbb866246176dcab215141f756acdc23c67fad149710eb1">Disconnected</a>
, <br />
&#160;&#160;<a class="el" href="classsf_1_1Socket.html#a51bf0fd51057b98a10fbb866246176dca1dc9854433a28c22e192721179a2df5d">Error</a>
<br />
 }</td></tr>
<tr class="memdesc:a51bf0fd51057b98a10fbb866246176dc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Status codes that may be returned by socket functions.  <a href="classsf_1_1Socket.html#a51bf0fd51057b98a10fbb866246176dc">More...</a><br /></td></tr>
<tr class="separator:a51bf0fd51057b98a10fbb866246176dc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa3e6c984bcb81a35234dcc9cc8369d75"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom">{ <a class="el" href="classsf_1_1Socket.html#aa3e6c984bcb81a35234dcc9cc8369d75a5a3c30fd128895403afc11076f461b19">AnyPort</a> = 0
 }</td></tr>
<tr class="memdesc:aa3e6c984bcb81a35234dcc9cc8369d75"><td class="mdescLeft">&#160;</td><td class="mdescRight">Some special values used by sockets.  <a href="classsf_1_1Socket.html#aa3e6c984bcb81a35234dcc9cc8369d75">More...</a><br /></td></tr>
<tr class="separator:aa3e6c984bcb81a35234dcc9cc8369d75"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a59a1db5b6f4711a3e57390da2f8d9630"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1TcpListener.html#a59a1db5b6f4711a3e57390da2f8d9630">TcpListener</a> ()</td></tr>
<tr class="memdesc:a59a1db5b6f4711a3e57390da2f8d9630"><td class="mdescLeft">&#160;</td><td class="mdescRight">Default constructor.  <br /></td></tr>
<tr class="separator:a59a1db5b6f4711a3e57390da2f8d9630"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a784b9a9c59d4cdbae1795e90b8015780"><td class="memItemLeft" align="right" valign="top">unsigned short&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1TcpListener.html#a784b9a9c59d4cdbae1795e90b8015780">getLocalPort</a> () const</td></tr>
<tr class="memdesc:a784b9a9c59d4cdbae1795e90b8015780"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the port to which the socket is bound locally.  <br /></td></tr>
<tr class="separator:a784b9a9c59d4cdbae1795e90b8015780"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9504758ea3570e62cb20b209c11776a1"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classsf_1_1Socket.html#a51bf0fd51057b98a10fbb866246176dc">Status</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1TcpListener.html#a9504758ea3570e62cb20b209c11776a1">listen</a> (unsigned short port, const <a class="el" href="classsf_1_1IpAddress.html">IpAddress</a> &amp;address=<a class="el" href="classsf_1_1IpAddress.html#a3dbc10b0dc6804cc69e29342f7406907">IpAddress::Any</a>)</td></tr>
<tr class="memdesc:a9504758ea3570e62cb20b209c11776a1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Start listening for incoming connection attempts.  <br /></td></tr>
<tr class="separator:a9504758ea3570e62cb20b209c11776a1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3a00a850506bd0f9f48867a0fe59556b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1TcpListener.html#a3a00a850506bd0f9f48867a0fe59556b">close</a> ()</td></tr>
<tr class="memdesc:a3a00a850506bd0f9f48867a0fe59556b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Stop listening and close the socket.  <br /></td></tr>
<tr class="separator:a3a00a850506bd0f9f48867a0fe59556b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae2c83ce5a64d50b68180c46bef0a7346"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classsf_1_1Socket.html#a51bf0fd51057b98a10fbb866246176dc">Status</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1TcpListener.html#ae2c83ce5a64d50b68180c46bef0a7346">accept</a> (<a class="el" href="classsf_1_1TcpSocket.html">TcpSocket</a> &amp;socket)</td></tr>
<tr class="memdesc:ae2c83ce5a64d50b68180c46bef0a7346"><td class="mdescLeft">&#160;</td><td class="mdescRight">Accept a new connection.  <br /></td></tr>
<tr class="separator:ae2c83ce5a64d50b68180c46bef0a7346"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a165fc1423e281ea2714c70303d3a9782"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1Socket.html#a165fc1423e281ea2714c70303d3a9782">setBlocking</a> (bool blocking)</td></tr>
<tr class="memdesc:a165fc1423e281ea2714c70303d3a9782"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set the blocking state of the socket.  <br /></td></tr>
<tr class="separator:a165fc1423e281ea2714c70303d3a9782"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab1ceca9ac114b8baeeda3b34a0aca468"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1Socket.html#ab1ceca9ac114b8baeeda3b34a0aca468">isBlocking</a> () const</td></tr>
<tr class="memdesc:ab1ceca9ac114b8baeeda3b34a0aca468"><td class="mdescLeft">&#160;</td><td class="mdescRight">Tell whether the socket is in blocking or non-blocking mode.  <br /></td></tr>
<tr class="separator:ab1ceca9ac114b8baeeda3b34a0aca468"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pro-types" name="pro-types"></a>
Protected Types</h2></td></tr>
<tr class="memitem:a5d3ff44e56e68f02816bb0fabc34adf8"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1Socket.html#a5d3ff44e56e68f02816bb0fabc34adf8">Type</a> { <a class="el" href="classsf_1_1Socket.html#a5d3ff44e56e68f02816bb0fabc34adf8acc02e97e90234b957eaad4dff7f22214">Tcp</a>
, <a class="el" href="classsf_1_1Socket.html#a5d3ff44e56e68f02816bb0fabc34adf8a6ebf3094830db4820191a327f3cc6ce2">Udp</a>
 }</td></tr>
<tr class="memdesc:a5d3ff44e56e68f02816bb0fabc34adf8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Types of protocols that the socket can use.  <a href="classsf_1_1Socket.html#a5d3ff44e56e68f02816bb0fabc34adf8">More...</a><br /></td></tr>
<tr class="separator:a5d3ff44e56e68f02816bb0fabc34adf8"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pro-methods" name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:a675457784284ae2f5640bbbe16729393"><td class="memItemLeft" align="right" valign="top">SocketHandle&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1Socket.html#a675457784284ae2f5640bbbe16729393">getHandle</a> () const</td></tr>
<tr class="memdesc:a675457784284ae2f5640bbbe16729393"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the internal handle of the socket.  <br /></td></tr>
<tr class="separator:a675457784284ae2f5640bbbe16729393"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aafbe140f4b1921e0d19e88cf7a61dcbc"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1Socket.html#aafbe140f4b1921e0d19e88cf7a61dcbc">create</a> ()</td></tr>
<tr class="memdesc:aafbe140f4b1921e0d19e88cf7a61dcbc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create the internal representation of the socket.  <br /></td></tr>
<tr class="separator:aafbe140f4b1921e0d19e88cf7a61dcbc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af1dd898f7aa3ead7ff7b2d1c20e97781"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1Socket.html#af1dd898f7aa3ead7ff7b2d1c20e97781">create</a> (SocketHandle handle)</td></tr>
<tr class="memdesc:af1dd898f7aa3ead7ff7b2d1c20e97781"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create the internal representation of the socket from a socket handle.  <br /></td></tr>
<tr class="separator:af1dd898f7aa3ead7ff7b2d1c20e97781"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p><a class="el" href="classsf_1_1Socket.html" title="Base class for all the socket types.">Socket</a> that listens to new TCP connections. </p>
<p>A listener socket is a special type of socket that listens to a given port and waits for connections on that port.</p>
<p>This is all it can do.</p>
<p>When a new connection is received, you must call accept and the listener returns a new instance of <a class="el" href="classsf_1_1TcpSocket.html" title="Specialized socket using the TCP protocol.">sf::TcpSocket</a> that is properly initialized and can be used to communicate with the new client.</p>
<p><a class="el" href="classsf_1_1Listener.html" title="The audio listener is the point in the scene from where all the sounds are heard.">Listener</a> sockets are specific to the TCP protocol, UDP sockets are connectionless and can therefore communicate directly. As a consequence, a listener socket will always return the new connections as <a class="el" href="classsf_1_1TcpSocket.html" title="Specialized socket using the TCP protocol.">sf::TcpSocket</a> instances.</p>
<p>A listener is automatically closed on destruction, like all other types of socket. However if you want to stop listening before the socket is destroyed, you can call its <a class="el" href="classsf_1_1TcpListener.html#a3a00a850506bd0f9f48867a0fe59556b" title="Stop listening and close the socket.">close()</a> function.</p>
<p>Usage example: </p><div class="fragment"><div class="line"><span class="comment">// Create a listener socket and make it wait for new</span></div>
<div class="line"><span class="comment">// connections on port 55001</span></div>
<div class="line"><a class="code hl_class" href="classsf_1_1TcpListener.html">sf::TcpListener</a> listener;</div>
<div class="line">listener.<a class="code hl_function" href="classsf_1_1TcpListener.html#a9504758ea3570e62cb20b209c11776a1">listen</a>(55001);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Endless loop that waits for new connections</span></div>
<div class="line"><span class="keywordflow">while</span> (running)</div>
<div class="line">{</div>
<div class="line">    <a class="code hl_class" href="classsf_1_1TcpSocket.html">sf::TcpSocket</a> client;</div>
<div class="line">    <span class="keywordflow">if</span> (listener.<a class="code hl_function" href="classsf_1_1TcpListener.html#ae2c83ce5a64d50b68180c46bef0a7346">accept</a>(client) == <a class="code hl_enumvalue" href="classsf_1_1Socket.html#a51bf0fd51057b98a10fbb866246176dca1de3a85bc56d3ae85b3d0f3cfd04ae90">sf::Socket::Done</a>)</div>
<div class="line">    {</div>
<div class="line">        <span class="comment">// A new client just connected!</span></div>
<div class="line">        std::cout &lt;&lt; <span class="stringliteral">&quot;New connection received from &quot;</span> &lt;&lt; client.<a class="code hl_function" href="classsf_1_1TcpSocket.html#aa8579c203b1fd21beb74d7f76444a94c">getRemoteAddress</a>() &lt;&lt; std::endl;</div>
<div class="line">        doSomethingWith(client);</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="ttc" id="aclasssf_1_1Socket_html_a51bf0fd51057b98a10fbb866246176dca1de3a85bc56d3ae85b3d0f3cfd04ae90"><div class="ttname"><a href="classsf_1_1Socket.html#a51bf0fd51057b98a10fbb866246176dca1de3a85bc56d3ae85b3d0f3cfd04ae90">sf::Socket::Done</a></div><div class="ttdeci">@ Done</div><div class="ttdoc">The socket has sent / received the data.</div><div class="ttdef"><b>Definition</b> <a href="Socket_8hpp_source.html#l00055">Socket.hpp:55</a></div></div>
<div class="ttc" id="aclasssf_1_1TcpListener_html"><div class="ttname"><a href="classsf_1_1TcpListener.html">sf::TcpListener</a></div><div class="ttdoc">Socket that listens to new TCP connections.</div><div class="ttdef"><b>Definition</b> <a href="TcpListener_8hpp_source.html#l00044">TcpListener.hpp:45</a></div></div>
<div class="ttc" id="aclasssf_1_1TcpListener_html_a9504758ea3570e62cb20b209c11776a1"><div class="ttname"><a href="classsf_1_1TcpListener.html#a9504758ea3570e62cb20b209c11776a1">sf::TcpListener::listen</a></div><div class="ttdeci">Status listen(unsigned short port, const IpAddress &amp;address=IpAddress::Any)</div><div class="ttdoc">Start listening for incoming connection attempts.</div></div>
<div class="ttc" id="aclasssf_1_1TcpListener_html_ae2c83ce5a64d50b68180c46bef0a7346"><div class="ttname"><a href="classsf_1_1TcpListener.html#ae2c83ce5a64d50b68180c46bef0a7346">sf::TcpListener::accept</a></div><div class="ttdeci">Status accept(TcpSocket &amp;socket)</div><div class="ttdoc">Accept a new connection.</div></div>
<div class="ttc" id="aclasssf_1_1TcpSocket_html"><div class="ttname"><a href="classsf_1_1TcpSocket.html">sf::TcpSocket</a></div><div class="ttdoc">Specialized socket using the TCP protocol.</div><div class="ttdef"><b>Definition</b> <a href="TcpSocket_8hpp_source.html#l00046">TcpSocket.hpp:47</a></div></div>
<div class="ttc" id="aclasssf_1_1TcpSocket_html_aa8579c203b1fd21beb74d7f76444a94c"><div class="ttname"><a href="classsf_1_1TcpSocket.html#aa8579c203b1fd21beb74d7f76444a94c">sf::TcpSocket::getRemoteAddress</a></div><div class="ttdeci">IpAddress getRemoteAddress() const</div><div class="ttdoc">Get the address of the connected peer.</div></div>
</div><!-- fragment --><dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1TcpSocket.html" title="Specialized socket using the TCP protocol.">sf::TcpSocket</a>, <a class="el" href="classsf_1_1Socket.html" title="Base class for all the socket types.">sf::Socket</a> </dd></dl>

<p class="definition">Definition at line <a class="el" href="TcpListener_8hpp_source.html#l00044">44</a> of file <a class="el" href="TcpListener_8hpp_source.html">TcpListener.hpp</a>.</p>
</div><h2 class="groupheader">Member Enumeration Documentation</h2>
<a id="aa3e6c984bcb81a35234dcc9cc8369d75" name="aa3e6c984bcb81a35234dcc9cc8369d75"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa3e6c984bcb81a35234dcc9cc8369d75">&#9670;&#160;</a></span>anonymous enum</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">anonymous enum</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inherited</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Some special values used by sockets. </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="aa3e6c984bcb81a35234dcc9cc8369d75a5a3c30fd128895403afc11076f461b19" name="aa3e6c984bcb81a35234dcc9cc8369d75a5a3c30fd128895403afc11076f461b19"></a>AnyPort&#160;</td><td class="fielddoc"><p>Special value that tells the system to pick any available port. </p>
</td></tr>
</table>

<p class="definition">Definition at line <a class="el" href="Socket_8hpp_source.html#l00066">66</a> of file <a class="el" href="Socket_8hpp_source.html">Socket.hpp</a>.</p>

</div>
</div>
<a id="a51bf0fd51057b98a10fbb866246176dc" name="a51bf0fd51057b98a10fbb866246176dc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a51bf0fd51057b98a10fbb866246176dc">&#9670;&#160;</a></span>Status</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="classsf_1_1Socket.html#a51bf0fd51057b98a10fbb866246176dc">sf::Socket::Status</a></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inherited</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Status codes that may be returned by socket functions. </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="a51bf0fd51057b98a10fbb866246176dca1de3a85bc56d3ae85b3d0f3cfd04ae90" name="a51bf0fd51057b98a10fbb866246176dca1de3a85bc56d3ae85b3d0f3cfd04ae90"></a>Done&#160;</td><td class="fielddoc"><p>The socket has sent / received the data. </p>
</td></tr>
<tr><td class="fieldname"><a id="a51bf0fd51057b98a10fbb866246176dca8554848daae98f996e131bdeed076c09" name="a51bf0fd51057b98a10fbb866246176dca8554848daae98f996e131bdeed076c09"></a>NotReady&#160;</td><td class="fielddoc"><p>The socket is not ready to send / receive data yet. </p>
</td></tr>
<tr><td class="fieldname"><a id="a51bf0fd51057b98a10fbb866246176dca181c163fad2eaea927185d127c392706" name="a51bf0fd51057b98a10fbb866246176dca181c163fad2eaea927185d127c392706"></a>Partial&#160;</td><td class="fielddoc"><p>The socket sent a part of the data. </p>
</td></tr>
<tr><td class="fieldname"><a id="a51bf0fd51057b98a10fbb866246176dcab215141f756acdc23c67fad149710eb1" name="a51bf0fd51057b98a10fbb866246176dcab215141f756acdc23c67fad149710eb1"></a>Disconnected&#160;</td><td class="fielddoc"><p>The TCP socket has been disconnected. </p>
</td></tr>
<tr><td class="fieldname"><a id="a51bf0fd51057b98a10fbb866246176dca1dc9854433a28c22e192721179a2df5d" name="a51bf0fd51057b98a10fbb866246176dca1dc9854433a28c22e192721179a2df5d"></a>Error&#160;</td><td class="fielddoc"><p>An unexpected error happened. </p>
</td></tr>
</table>

<p class="definition">Definition at line <a class="el" href="Socket_8hpp_source.html#l00053">53</a> of file <a class="el" href="Socket_8hpp_source.html">Socket.hpp</a>.</p>

</div>
</div>
<a id="a5d3ff44e56e68f02816bb0fabc34adf8" name="a5d3ff44e56e68f02816bb0fabc34adf8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5d3ff44e56e68f02816bb0fabc34adf8">&#9670;&#160;</a></span>Type</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="classsf_1_1Socket.html#a5d3ff44e56e68f02816bb0fabc34adf8">sf::Socket::Type</a></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">inherited</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Types of protocols that the socket can use. </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="a5d3ff44e56e68f02816bb0fabc34adf8acc02e97e90234b957eaad4dff7f22214" name="a5d3ff44e56e68f02816bb0fabc34adf8acc02e97e90234b957eaad4dff7f22214"></a>Tcp&#160;</td><td class="fielddoc"><p>TCP protocol. </p>
</td></tr>
<tr><td class="fieldname"><a id="a5d3ff44e56e68f02816bb0fabc34adf8a6ebf3094830db4820191a327f3cc6ce2" name="a5d3ff44e56e68f02816bb0fabc34adf8a6ebf3094830db4820191a327f3cc6ce2"></a>Udp&#160;</td><td class="fielddoc"><p>UDP protocol. </p>
</td></tr>
</table>

<p class="definition">Definition at line <a class="el" href="Socket_8hpp_source.html#l00114">114</a> of file <a class="el" href="Socket_8hpp_source.html">Socket.hpp</a>.</p>

</div>
</div>
<h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a59a1db5b6f4711a3e57390da2f8d9630" name="a59a1db5b6f4711a3e57390da2f8d9630"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a59a1db5b6f4711a3e57390da2f8d9630">&#9670;&#160;</a></span>TcpListener()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">sf::TcpListener::TcpListener </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Default constructor. </p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="ae2c83ce5a64d50b68180c46bef0a7346" name="ae2c83ce5a64d50b68180c46bef0a7346"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae2c83ce5a64d50b68180c46bef0a7346">&#9670;&#160;</a></span>accept()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classsf_1_1Socket.html#a51bf0fd51057b98a10fbb866246176dc">Status</a> sf::TcpListener::accept </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classsf_1_1TcpSocket.html">TcpSocket</a> &amp;&#160;</td>
          <td class="paramname"><em>socket</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Accept a new connection. </p>
<p>If the socket is in blocking mode, this function will not return until a connection is actually received.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">socket</td><td><a class="el" href="classsf_1_1Socket.html" title="Base class for all the socket types.">Socket</a> that will hold the new connection</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Status code</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1TcpListener.html#a9504758ea3570e62cb20b209c11776a1" title="Start listening for incoming connection attempts.">listen</a> </dd></dl>

</div>
</div>
<a id="a3a00a850506bd0f9f48867a0fe59556b" name="a3a00a850506bd0f9f48867a0fe59556b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3a00a850506bd0f9f48867a0fe59556b">&#9670;&#160;</a></span>close()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void sf::TcpListener::close </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Stop listening and close the socket. </p>
<p>This function gracefully stops the listener. If the socket is not listening, this function has no effect.</p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1TcpListener.html#a9504758ea3570e62cb20b209c11776a1" title="Start listening for incoming connection attempts.">listen</a> </dd></dl>

</div>
</div>
<a id="aafbe140f4b1921e0d19e88cf7a61dcbc" name="aafbe140f4b1921e0d19e88cf7a61dcbc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aafbe140f4b1921e0d19e88cf7a61dcbc">&#9670;&#160;</a></span>create() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void sf::Socket::create </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">inherited</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Create the internal representation of the socket. </p>
<p>This function can only be accessed by derived classes. </p>

</div>
</div>
<a id="af1dd898f7aa3ead7ff7b2d1c20e97781" name="af1dd898f7aa3ead7ff7b2d1c20e97781"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af1dd898f7aa3ead7ff7b2d1c20e97781">&#9670;&#160;</a></span>create() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void sf::Socket::create </td>
          <td>(</td>
          <td class="paramtype">SocketHandle&#160;</td>
          <td class="paramname"><em>handle</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">inherited</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Create the internal representation of the socket from a socket handle. </p>
<p>This function can only be accessed by derived classes.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">handle</td><td>OS-specific handle of the socket to wrap </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a675457784284ae2f5640bbbe16729393" name="a675457784284ae2f5640bbbe16729393"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a675457784284ae2f5640bbbe16729393">&#9670;&#160;</a></span>getHandle()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">SocketHandle sf::Socket::getHandle </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">inherited</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Return the internal handle of the socket. </p>
<p>The returned handle may be invalid if the socket was not created yet (or already destroyed). This function can only be accessed by derived classes.</p>
<dl class="section return"><dt>Returns</dt><dd>The internal (OS-specific) handle of the socket </dd></dl>

</div>
</div>
<a id="a784b9a9c59d4cdbae1795e90b8015780" name="a784b9a9c59d4cdbae1795e90b8015780"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a784b9a9c59d4cdbae1795e90b8015780">&#9670;&#160;</a></span>getLocalPort()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned short sf::TcpListener::getLocalPort </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get the port to which the socket is bound locally. </p>
<p>If the socket is not listening to a port, this function returns 0.</p>
<dl class="section return"><dt>Returns</dt><dd>Port to which the socket is bound</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1TcpListener.html#a9504758ea3570e62cb20b209c11776a1" title="Start listening for incoming connection attempts.">listen</a> </dd></dl>

</div>
</div>
<a id="ab1ceca9ac114b8baeeda3b34a0aca468" name="ab1ceca9ac114b8baeeda3b34a0aca468"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab1ceca9ac114b8baeeda3b34a0aca468">&#9670;&#160;</a></span>isBlocking()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool sf::Socket::isBlocking </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inherited</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Tell whether the socket is in blocking or non-blocking mode. </p>
<dl class="section return"><dt>Returns</dt><dd>True if the socket is blocking, false otherwise</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1Socket.html#a165fc1423e281ea2714c70303d3a9782" title="Set the blocking state of the socket.">setBlocking</a> </dd></dl>

</div>
</div>
<a id="a9504758ea3570e62cb20b209c11776a1" name="a9504758ea3570e62cb20b209c11776a1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9504758ea3570e62cb20b209c11776a1">&#9670;&#160;</a></span>listen()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classsf_1_1Socket.html#a51bf0fd51057b98a10fbb866246176dc">Status</a> sf::TcpListener::listen </td>
          <td>(</td>
          <td class="paramtype">unsigned short&#160;</td>
          <td class="paramname"><em>port</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classsf_1_1IpAddress.html">IpAddress</a> &amp;&#160;</td>
          <td class="paramname"><em>address</em> = <code><a class="el" href="classsf_1_1IpAddress.html#a3dbc10b0dc6804cc69e29342f7406907">IpAddress::Any</a></code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Start listening for incoming connection attempts. </p>
<p>This function makes the socket start listening on the specified port, waiting for incoming connection attempts.</p>
<p>If the socket is already listening on a port when this function is called, it will stop listening on the old port before starting to listen on the new port.</p>
<p>When providing <a class="el" href="classsf_1_1Socket.html#aa3e6c984bcb81a35234dcc9cc8369d75a5a3c30fd128895403afc11076f461b19" title="Special value that tells the system to pick any available port.">sf::Socket::AnyPort</a> as port, the listener will request an available port from the system. The chosen port can be retrieved by calling <a class="el" href="classsf_1_1TcpListener.html#a784b9a9c59d4cdbae1795e90b8015780" title="Get the port to which the socket is bound locally.">getLocalPort()</a>.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">port</td><td>Port to listen on for incoming connection attempts </td></tr>
    <tr><td class="paramname">address</td><td>Address of the interface to listen on</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Status code</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1TcpListener.html#ae2c83ce5a64d50b68180c46bef0a7346" title="Accept a new connection.">accept</a>, <a class="el" href="classsf_1_1TcpListener.html#a3a00a850506bd0f9f48867a0fe59556b" title="Stop listening and close the socket.">close</a> </dd></dl>

</div>
</div>
<a id="a165fc1423e281ea2714c70303d3a9782" name="a165fc1423e281ea2714c70303d3a9782"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a165fc1423e281ea2714c70303d3a9782">&#9670;&#160;</a></span>setBlocking()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void sf::Socket::setBlocking </td>
          <td>(</td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>blocking</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inherited</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Set the blocking state of the socket. </p>
<p>In blocking mode, calls will not return until they have completed their task. For example, a call to Receive in blocking mode won't return until some data was actually received. In non-blocking mode, calls will always return immediately, using the return code to signal whether there was data available or not. By default, all sockets are blocking.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">blocking</td><td>True to set the socket as blocking, false for non-blocking</td></tr>
  </table>
  </dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1Socket.html#ab1ceca9ac114b8baeeda3b34a0aca468" title="Tell whether the socket is in blocking or non-blocking mode.">isBlocking</a> </dd></dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="TcpListener_8hpp_source.html">TcpListener.hpp</a></li>
</ul>
</div><!-- contents -->
        </div>
        <div id="footer-container">
            <div id="footer">
                SFML is licensed under the terms and conditions of the <a href="https://www.sfml-dev.org/license.php">zlib/png license</a>.<br>
                Copyright &copy; Laurent Gomila &nbsp;::&nbsp;
                Documentation generated by <a href="http://www.doxygen.org/" title="doxygen website">doxygen</a> &nbsp;::&nbsp;
            </div>
        </div>
    </body>
</html>
